#pragma once
#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
const std::string pipeFile = "./fifo";
const mode_t mode = 0600; // 所属人有全部权限
const int defaultfd = -1;
const int gsize = 1024;
const int openForWrite = O_WRONLY;
const int openForRead = O_RDONLY;

#define OPEN(FLAG, _fd)                                                 \
    int n = ::open(pipeFile.c_str(), FLAG);                             \
    if (n < 0)                                                          \
    {                                                                   \
        std::cerr << "openfifo error:" << strerror(errno) << std::endl; \
        return false;                                                   \
    }                                                                   \
    _fd = n;

#define CLOSEPIPE(_fd) \
    if (_fd > 0)       \
        ::close(_fd);
